package event

import (
	"awesomeTask/application/models/master"
	"awesomeTask/application/variable"
	"awesomeTask/application/vote"
	"awesomeTask/system/event"
	"awesomeTask/system/kernel"
	"awesomeTask/system/log"
	"os"
)

func Init() {
	event.Register("appStartEvent", func(args ...interface{}) {
		instance := kernel.GetIocInstance()
		fileLoger := instance.GetInstanceOrCreate("logger").(log.FileLoger)
		fileLoger.Info("application start")
	})

	event.Register(variable.ON_LAUNCH_VOTE, func(args ...interface{}) {
		voteObj := vote.VoteHandler{}
		voteObj.AcceptLaunchRequest(args[0].(map[string]interface{}))
		voteObj.Vote(int(args[0].(map[string]interface{})["voteCode"].(float64)))
	})
	event.Register(variable.ON_ACCEPT_VOTE, func(args ...interface{}) {
		voteObj := vote.VoteHandler{}
		voteObj.AcceptLaunchRequest(args[0].(map[string]interface{}))
	})
	event.Register(variable.ON_AS_MASTER, func(args ...interface{}) {
		master.GetMasterObj().RegisterMaster()
	})
	os.Getenv("")
}
